#!/usr/bin/env python

from celtuce.accessor import Accessor

import time

from celtuce.help import logging
logging.getLogger().setLevel(logging.LEVEL_DEBUG)

URL = 'tcp://127.0.0.1:14300'

TABLE = 'table_test'

def runTest() :
    accessor = Accessor( URL )
    try :
        # insert
        response = accessor.insert(TABLE,'hello', 'world')
        assert response.isOk()

        # find
        response = accessor.find(TABLE, 'hello')
        assert response.isOk()
        _key,_value = response.body
        assert _key == 'hello'
        assert _value == 'world'

        # erase
        response = accessor.erase(TABLE, 'hello')
        assert response.isOk()

        # find
        key = 'hello'
        response = accessor.find(TABLE, key)
        assert response.isOk()
        _key,_value = response.body
        assert _key == key
        assert _value is None

    finally :
        accessor.shutdown()

    ## runTest()

if  __name__ == '__main__' :
    runTest()

